<?php

namespace Modules\Permission\Http\Controllers;
use Modules\Permission\Http\Requests\PermissionRequest;
use Modules\Permission\Transformers\MenuResource;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Modules\Common\Http\Controllers\CommonController;
use Modules\Permission\Services\PermissionService;
use Modules\Common\Transformers\CommonResource;
use Modules\Permission\Entities\Permission;
class PermissionController extends CommonController
{
    private $service;
    public function __construct(PermissionService $service) {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     * @return Renderable
     */
    public function index()
    {
        return $this->success(new MenuResource(Permission::admin()->get()));
    }

    /**
     * Show the form for creating a new resource.
     * @return Renderable
     */
    public function create()
    {
        return view('permission::create');
    }

    /**
     * Store a newly created resource in storage.
     * @param Request $request
     * @return Renderable
     */
    public function store(PermissionRequest $request)
    {
        $result = $this->service->store($request->all());
        return $this->created($result);
    }

    /**
     * Show the specified resource.
     * @param int $id
     * @return Renderable
     */
    public function show()
    {
        $item = $this->queryBuilder($this->service->queryPermissions())->aFilters([])->aIncludes([])->get();
        return $this->success($item );
    }

    /**
     * Show the form for editing the specified resource.
     * @param int $id
     * @return Renderable
     */
    public function edit($id)
    {
        return view('permission::edit');
    }

    /**
     * Update the specified resource in storage.
     * @param Request $request
     * @param int $id
     * @return Renderable
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     * @param int $id
     * @return Renderable
     */
    public function destroy($id)
    {
        //
    }
}
